package com.xunk.system.config;

import com.xunk.common.core.constant.CacheConstants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;

@Configuration
@RefreshScope
public class BuzConfig {

    @Autowired
    private RedisConnectionFactory redisConnectionFactory;

    /**
     * 如影开放平台接口链接
     */
    @Value("${iot.ruying.apiUrl}")
    private String ruyingIotApiUrl;

    /**
     * 如影开放平台 产品信息接口链接
     */
    @Value("${iot.ruying.specUrl}")
    private String ruyingIotSpecUrl;

    /**
     * 海纳云在如影平台的appid
     */
    @Value("${iot.ruying.appId}")
    private String ruyingIotAppId;

    @Value("${iot.ruying.serectKey}")
    private String ruyingIotSerectKey;

    @Value("${image.server.ip:}")
    private String imageServerIp;

    @Bean
    public TokenStore tokenStore() {
        RedisTokenStore tokenStore = new RedisTokenStore(redisConnectionFactory);
        tokenStore.setPrefix(CacheConstants.OAUTH_ACCESS);
        return tokenStore;
    }


    public String getRuyingIotSerectKey() {
        return ruyingIotSerectKey;
    }

    public void setRuyingIotSerectKey(String ruyingIotSerectKey) {
        this.ruyingIotSerectKey = ruyingIotSerectKey;
    }

    public String getRuyingIotAppId() {
        return ruyingIotAppId;
    }

    public void setRuyingIotAppId(String ruyingIotAppId) {
        this.ruyingIotAppId = ruyingIotAppId;
    }

    public String getRuyingIotApiUrl() {
        return ruyingIotApiUrl;
    }

    public void setRuyingIotApiUrl(String ruyingIotApiUrl) {
        this.ruyingIotApiUrl = ruyingIotApiUrl;
    }


    public String getRuyingIotSpecUrl() {
        return ruyingIotSpecUrl;
    }

    public void setRuyingIotSpecUrl(String ruyingIotSpecUrl) {
        this.ruyingIotSpecUrl = ruyingIotSpecUrl;
    }

    public String getImageServerIp() {
        return imageServerIp;
    }

    public void setImageServerIp(String imageServerIp) {
        this.imageServerIp = imageServerIp;
    }
}
